package com.travel.bhelp.user.controller;

import com.travel.bhelp.common.model.Result;
import com.travel.bhelp.user.model.JobPost;
import com.travel.bhelp.user.service.JobPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/job")
public class JobPostController {

    @Autowired
    private JobPostService jobPostService;

    @PostMapping
    public Result createJobPost(@RequestBody JobPost jobPost) {
        return jobPostService.createJobPost(jobPost);
    }

    @PutMapping
    public Result updateJobPost(@RequestBody JobPost jobPost) {
        return jobPostService.updateJobPost(jobPost);
    }

    @DeleteMapping("/{id}")
    public Result deleteJobPost(@PathVariable Long id) {
        return jobPostService.deleteJobPost(id);
    }

    @GetMapping("/user/{userId}")
    public Result getJobPostsByUser(@PathVariable Long userId) {
        return Result.success(jobPostService.getJobPostsByUser(userId));
    }

    @GetMapping
    public Result getAllJobPosts() {
        return Result.success(jobPostService.getAllJobPosts());
    }
}
